package cn.dapeng.comparator;

import java.util.Comparator;

/**
 * 自定义比较器
 * 实现自定义排序规则
 *
 * 倒序 使用排序结果乘以-1处理
 */
public class SkuInfoComparator implements Comparator<SkuInfo> {

    @Override
    public int compare(SkuInfo o1, SkuInfo o2) {
        int r = o1.getStoryId().compareTo(o2.getStoryId()) * -1;
        if (r == 0) {
            r = o1.getSkuId().compareTo(o2.getSkuId());

            if (r == 0) {
                r = o1.getScore().compareTo(o2.getScore()) * -1;
            }
        }
        return r;
    }
}
